package com.example.app2024.fragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.LinearLayout;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;

import com.example.app2024.R;

public class Fragment_dymic extends Fragment
{

      LinearLayout linearLayout;
      Button btn;
      FragmentManager manager;

      @Nullable
      @Override
      public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState)
      {
            linearLayout = getActivity().findViewById(R.id.left31);


            View view = inflater.inflate(R.layout.layout1, container, false);
            btn = view.findViewById(R.id.button);
            btn.setOnClickListener(new View.OnClickListener()
            {
                  @Override
                  public void onClick(View v)
                  {
                        manager = getFragmentManager();
                        FragmentTransaction transaction = manager.beginTransaction();
                        transaction.remove(Fragment_dymic.this);
                        transaction.commit();
                        maxScreen();
                  }
            });
            return view;
      }

      @Override
      public void onDestroyView()
      {
            maxScreen();
            super.onDestroyView();
      }

      private void maxScreen()
      {
            linearLayout.setLayoutParams(new LinearLayout.LayoutParams(getActivity().getWindowManager().getDefaultDisplay().getWidth(), getActivity().getWindowManager().getDefaultDisplay().getHeight()));
      }
}
